from main import db
import datetime


class SearchHistory(db.Model):
    __tablename__ = "search"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    text = db.Column(db.String(50), nullable=False)
    search_engine_id = db.Column(db.Integer, nullable=False, default=0)

    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    user = db.relationship('TagUser', backref='searches', foreign_keys=[user_id], lazy=True)

    create_at = db.Column(db.DateTime, default=datetime.datetime.now)
